Python diskcache.Cache方法代码示例 您所在的位置:网站首页 Python使用本地缓存库diskcache Python diskcache.Cache方法代码示例

Python diskcache.Cache方法代码示例

2024-05-29 04:28| 来源: 网络整理| 查看: 265

本文整理汇总了Python中diskcache.Cache方法的典型用法代码示例。如果您正苦于以下问题:Python diskcache.Cache方法的具体用法?Python diskcache.Cache怎么用?Python diskcache.Cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在diskcache的用法示例。

在下文中一共展示了diskcache.Cache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load_file_cache # 需要导入模块: import diskcache [as 别名] # 或者: from diskcache import Cache [as 别名] def _load_file_cache(filename, database_format, encoding, frame_id_mask, strict, cache_dir): with open(filename, 'rb') as fin: key = fin.read() cache = diskcache.Cache(cache_dir) try: return cache[key] except KeyError: with fopen(filename, 'r', encoding=encoding) as fin: database = load(fin, database_format, frame_id_mask, strict) cache[key] = database return database 开发者ID:eerimoq,项目名称:cantools,代码行数:24,代码来源:__init__.py 示例2: feature_extract # 需要导入模块: import diskcache [as 别名] # 或者: from diskcache import Cache [as 别名] def feature_extract(table_name, filepath): names = [] feats = [] cache = Cache(default_cache_dir) total = len(open(filepath,'rU').readlines()) cache['total'] = total current = 0 with open(filepath, 'r') as f: for line in f: current += 1 cache['current'] = current line = line.strip() line = line.split() line = line[0] try: vec = smiles_to_vec(line) feats.append(vec) names.append(line.encode()) except: continue print ("extracting feature from smi No. %d , %d molecular in total" %(current, total)) return feats, names 开发者ID:milvus-io,项目名称:bootcamp,代码行数:24,代码来源:encode.py 示例3: do_train # 需要导入模块: import diskcache [as 别名] # 或者: from diskcache import Cache [as 别名] def do_train(table_name, database_path): if not table_name: table_name = DEFAULT_TABLE cache = Cache(default_cache_dir) try: vectors, names = feature_extract(database_path, VGGNet()) index_client = milvus_client() # delete_table(index_client, table_name=table_name) # time.sleep(1) status, ok = has_table(index_client, table_name) if not ok: print("create table.") create_table(index_client, table_name=table_name) print("insert into:", table_name) status, ids = insert_vectors(index_client, table_name, vectors) create_index(index_client, table_name) for i in range(len(names)): # cache[names[i]] = ids[i] cache[ids[i]] = names[i] print("Train finished") return "Train finished" except Exception as e: logging.error(e) return "Error with {}".format(e) 开发者ID:milvus-io,项目名称:bootcamp,代码行数:26,代码来源:train.py 示例4: test_cache_merfish # 需要导入模块: import diskcache [as 别名] # 或者: from diskcache import Cache [as 别名] def test_cache_merfish(tmpdir, name, expected, config, monkeypatch): cache_enabled = (0 != config["slicedimage"]["caching"].get("size_limit", None)) if cache_enabled: config["slicedimage"]["caching"]["directory"] = str(tmpdir / "caching") with monkeypatch.context() as mc: setup_config(config, tmpdir, mc) # Run 1 data.MERFISH(use_test_data=True).fov().get_image("primary") # Run 2 if cache_enabled: data.MERFISH(use_test_data=True).fov().get_image("primary") # Check constraints if cache_enabled: # Enforce smallest size cache = Cache(str(tmpdir / "caching")) cache.cull() cache_size = get_size(tmpdir / "caching") min, max = expected assert (min


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有